<template>
	<view class="fui-wrap">
		<fui-result v-if="err" type="fail" title="操作失败" :descr="err">
			<fui-button @click="$reLaunch('merchant/index')" width="400rpx" height="84rpx" text="返回主页" type="success" bold :margin="['48rpx','0','24rpx']"></fui-button>
		</fui-result>
		<fui-list title="选择停车券类型：" v-else>
			<fui-list-cell v-for="(item,index) in list" arrow :key="index" @click="$navigateTo('merchant/'+type+'?id='+item.id)">
				<image :src="`${baseUrl}assets/img/miniapp/quan.png`" style="width: 100rpx;" mode="widthFix"></image>
				<view :style="(item.title && item.description && item.tips)?`position: relative;top: 12rpx;`:``">
					<fui-text :text="item.title" type="black" size="28" block></fui-text>
					<fui-text :text="item.description" v-if="item.description" type="gray" size="24" block></fui-text>
					<fui-text :text="item.tips" v-if="item.tips" color="red" size="24" block></fui-text>
				</view>
			</fui-list-cell>
		</fui-list>
		<pcfooter></pcfooter>
	</view>
</template>

<script>
	import {methods,baseUrl} from '@/utils/core.js';
	import pcfooter from '@/components/common/pcfooter.vue';
	export default {
		components:{
			pcfooter:pcfooter
		},
		data() {
			return {
				baseUrl:baseUrl,
				type:'',
				type_txt:{
					dynamic:'发券-动态码',
					static:'发券-固定码'
				},
				err:'',
				list:[]
			}
		},
		onLoad(e) {
			this.type=e.type;
			uni.setNavigationBarTitle({
				title:this.type_txt[e.type]
			});
			this.$platform();
			this.getCoupon();
		},
		methods: {
			...methods,
			getCoupon:function(){
				this.$get('merchant/index/coupon',{type:this.type},true).then(res=>{
					this.list=res;
				}).catch(err=>{
					this.err=err.msg;
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	
</style>